$(function () {
    $("#jqGrid").Grid({
        url: '../merchantassets/list',
        colModel: [
            {label: 'id', name: 'id', index: 'id', key: true, hidden: true},
            {label: '资金', name: 'amount', index: 'amount', width: 50},
            {label: '冻结资金', name: 'frozen', index: 'frozen', width: 50},
            {label: '商户名称', name: 'merchantName', index: 'merchantName', width: 50},
            {label: '提现数', name: 'cashOutTotal', index: 'cashOutTotal', width: 50},
            {label: '提现金额', name: 'cashOutTotalPrice', index: 'cashOutTotalPrice', width: 80},
            {label: '订单数', name: 'orderTotal', index: 'cashOutTotal', width: 50},
            {label: '订单金额', name: 'orderTotalPrice', index: 'cashOutTotalPrice', width: 80}
        ]
    });

    Ajax.request({
        url: "../sys/merchant/queryMerchant",
        async: true,
        successCallback: function (r) {
            vm.merchants = [];
            vm.merchants = r.list;
        }
    });
});

let vm = new Vue({
    el: '#rrapp',
    data: {
        showList: true,
        title: null,
        merchantassets: {},
        merchants:[],
        ruleValidate: {
            name: [
                {required: true, message: '名称不能为空', trigger: 'blur'}
            ]
        },
        q: {
            merchantId:''
        }
    },
    methods: {
        query: function () {
            vm.reload();
        },

        getInfo: function(){
            vm.showList = false;
            let id = getSelectedRow("#jqGrid");
            if (id == null) {
                return;
            }
            Ajax.request({
                url: "../merchantassets/info/"+id,
                async: true,
                successCallback: function (r) {
                    vm.merchantassets = r.merchantassets;
                }
            });
        },handleReset: function (name) {
            handleResetForm(this, name);
        },
        reload: function (event) {
            vm.showList = true;
            let page = $("#jqGrid").jqGrid('getGridParam', 'page');
            $("#jqGrid").jqGrid('setGridParam', {
                postData: {
                    'merchantId': vm.q.merchantId
                },
                page: page
            }).trigger("reloadGrid");
            vm.handleReset('formValidate');
        },
        reloadSearch: function() {
            vm.q = {
                merchantId:''
            }
            vm.reload();
        }
    }
});